﻿
Public Class clipboardTextWriter
    Public Const functionName As String = "cpbTWrt"

    Public Shared Function invoke(ByVal inlineScript As inlineScript, ByVal text As String, _
                                  Optional ByRef actionTarget As String = Nothing) As String
        assert(Not inlineScript Is Nothing, "inlineScript is nothing.")
        inlineScript.addscript(network.http.contentType.textjavascript, "clipboardTextWriter" _
                               , "function " + functionName + "(text) {window.clipboardData.setData('text',text);}")
        actionTarget += functionName + "(" + text + ")"
        Return actionTarget
    End Function
End Class

Public Class autoclipboardTextWriter
    Public Shared Sub invoke(ByVal page As xhtmlpage, ByVal text As String)
        assert(Not page Is Nothing AndAlso Not page.body() Is Nothing, _
               "page is not a xhtmlpage or page.body() is not a body.")
        Dim actionTarget As String = Nothing
        clipboardTextWriter.invoke(page.inlineScript, text, actionTarget)
        page.body().onload += actionTarget + ";"
    End Sub
End Class

Public Class clipboardTextReader
    Public Const functionName As String = "cpbTRdr"

    Public Shared Function invoke(ByVal inlineScript As inlineScript, _
                                  Optional ByRef actionTarget As String = Nothing) As String
        assert(Not inlineScript Is Nothing, "inlineScript is nothing.")
        inlineScript.addscript(network.http.contentType.textjavascript, "clipboardTextReader" _
                                 , "function " + functionName + "() {return window.clipboardData.getData('text');}")
        actionTarget += functionName + "()"
        Return actionTarget
    End Function
End Class

Public Class autoclipboardTextReader
    Public Shared Sub invoke(ByVal page As xhtmlpage)
        assert(Not page Is Nothing AndAlso Not page.body() Is Nothing, _
               "page is not a xhtmlpage or page.body() is not a body.")
        page.body().onload += clipboardTextReader.invoke(page.inlineScript()) + ";"
    End Sub
End Class